package com.ynrcc.intercept;

import java.util.List;

import com.eova.aop.AopContext;
import com.eova.aop.MetaObjectIntercept;
import com.ynrcc.model.UserBrch;

public class UserBrchIntercept extends MetaObjectIntercept {
	@Override
	public void queryBefore(AopContext ac) throws Exception {
		// 获取登录用户的数据权限
		String loginid = ac.user.getStr("LOGIN_ID");
		List<UserBrch> userbrchs = UserBrch.dao.findByLoginId(loginid);
		if (userbrchs.size() > 0) {
			String condition = userbrchs.get(0).getBrchPriv();
			ac.condition = condition;
			System.out.println("用户数据权限过滤，condidtion=[" + condition + "]");
		}else{
			ac.condition = " and (1=2)";
			System.out.println("用户数据权限未配置，查询结果为空！");
		}
	}
}
